from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
from selenium.webdriver.common.by import By
from selenium.webdriver import Chrome, Keys
from selenium.webdriver import ChromeOptions
from selenium.webdriver.common.action_chains import ActionChains
import requests


#规避检测
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36"
s = Service(executable_path=r'D:\Google\driver\chromedriver.exe')
driver = webdriver.Chrome(service=s)
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
option.add_argument('--user-agent=%s' % user_agent)
driver = Chrome(options=option)
def start():
    driver.maximize_window()  # 一定要窗口最大化处理
    # 输入网址
    driver.get("https://www.ibox.art/zh-cn/notice/")
    time.sleep(3)

    # 定位滑块元素
    sli_ele = driver.find_element(By.XPATH, '//*[@id="nc_1_n1z"]')

    # 创建鼠标操作对象
    action = ActionChains(driver)
    # 第一步：在滑块处按住鼠标左键
    action.click_and_hold(sli_ele)
    # 第二步：相对鼠标当前位置进行移动
    action.move_by_offset(65, 0)
    # 相对鼠标当前位置进行移动
    action.move_by_offset(65, 0)
    # 相对鼠标当前位置进行移动
    action.move_by_offset(65, 0)
    # 相对鼠标当前位置进行移动
    action.move_by_offset(65, 0)
    # 第三步：释放鼠标
    action.release()
    # 执行动作
    action.perform()
    time.sleep(1.5)


if __name__ == '__main__':
    start()
